/*
MIT Licence allows free use in all software (including GPL and commercial)

The licence text below is the boilerplate "MIT Licence" used from:
http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2012, An Pham

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef H_MFLINKTOOLREG
#define H_MFLINKTOOLREG

#include <winreg.h>
#include <string>

using namespace std;

/*
KEY_WOW64_64KEY	0x0100	Access a 64-bit key from either a 32-bit or 64-bit application.
KEY_WOW64_32KEY	0x0200	Access a 32-bit key from either a 32-bit or 64-bit application.
*/

class Registry
{
public:
    struct KeyInfo
    {
		char ClassName[1024];
		FILETIME LastWritten;
		DWORD ClassNameLength, MaxSubKeyName, MaxValueLength, MaxValueName, SubKeyCount, ValueCount;
    };
protected:
	HKEY Key;
	bool Changed;
public:
	string CurrentPath;
	HKEY RootKey;
	DWORD AccessMode, Wow64;
	bool LazyWrite, TrimString;	
public:
	Registry();
	virtual ~Registry();
	void closeKey();
	bool deleteKey(const string& AKey);
	bool deleteValue(const string& AName);
	bool keyExists(const string& AKey);
	bool keyInfo(KeyInfo& Info);
	bool openKey(const string& AKey, const bool ACanCreate = false);
	//OleDateTime readDateTime(const string& AName, const OleDateTime ADefault = 0.0);
	double readFloat(const string& AName, const double ADefault = 0.0);
	double readInt(const string& AName, const int ADefault = 0);
	string readString(const string& AName, const string ADefault = "");
	int subKeyCount();
	vector<string> subKeyNames();
	int valueDataSize(const string& AName);
	int valueDataType(const string& AName);
	bool valueExists(const string& AName);
	int valueCount();
	vector<string> valueNames();
	//bool writeDateTime(const string AName, const OleDateTime AValue);
	bool writeFloat(const string& AName, const double AValue);
	bool writeInt(const string& AName, const int AValue);
	bool writeString(const string& AName, const string& AValue);
};

#endif /* H_MFLINKTOOLREG */